package od;


import java.util.Scanner;

/**
 * Copyright (C) 2023 思创数码科技股份有限公司
 * <p/>
 * 版权所有
 * <p/>
 * 类名　　  : Test_1
 * 功能概要  :
 *
 * @author yangwk
 * @date 2025/3/4 19:58
 */
public class 字符切割 {
    static String minStr = "";
    static int theLength = 0;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        theLength = removeDup(str2).length();
        spit(str1, 0, "");
        if(minStr.length()==0){
            System.out.println("Not Found");
        }else{
            System.out.println(minStr);
        }

    }

    public static void spit(String str, int index, String preStr) {
        if (index == str.length()) {
            String realStr = removeDup(preStr);
            compare(realStr);
            return;
        }
        char c = str.charAt(index);
        if (isValid(c)&&!isInvalid(c)) {
            spit(str, index+1, preStr + c);
        } else {
            String realStr = removeDup(preStr);
            compare(realStr);
            spit(str, index+1, "");
            spit(str, index+1, preStr+c);

        }
    }

    public static void compare(String realStr) {
        if (realStr.length() <= theLength) {
            if(realStr.length() == minStr.length()){
                if (realStr.compareTo(minStr) > 0) {
                    minStr = realStr;
                }
            }
            if(realStr.length() >minStr.length()){
                minStr = realStr;
            }

        }
    }

    public static boolean isValid(Character c) {
        if (Character.isDigit(c)) {
            return true;
        }
        return c >= 'a' && c <= 'z';
    }

    public static boolean isInvalid(Character c) {
        if (Character.isDigit(c)) {
            return true;
        }
        return c >= 'a' && c <= 'f';
    }

    public static String removeDup(String str) {
        StringBuilder set = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            if (set.indexOf(str.charAt(i) + "") == -1) {
                set.append(str.charAt(i));
            }
        }
        return set.toString();
    }
}
